﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MoPhongThuatToan
{
    class TPLT:MaTran
    {
        string chuoi = null;
        private int d = 0;
        private int[] nhan = new int[spt];
        public void ViSit(int i, int lb)
        {
            nhan[i]=lb;
            for (int j = 0; j < spt; j++)
            {
                if (nhan[j] == 0 && (a[i, j] > 0))
                {
                    d = j;
                    chuoi = chuoi + " , " + j.ToString();
                    ViSit(j, lb);
                }
            }
        }
        public string FindConnected()
        {
            int lb=0;
            for(int i=0;i<spt;i++)
                nhan[i]=0;
            for (int i = 0; i < spt; i++)
            {
                if (nhan[i] == 0)
                {
                    if (chuoi != null)
                    {
                        chuoi = chuoi + "\r\n";
                    }
                    lb++;
                    chuoi = chuoi + "Thanh phan lien thong thu" + lb.ToString() + " là: " + i.ToString();
                    ViSit(i, lb);
                }
            }
            return chuoi;
        }
        
    }
}
